Check for a number at the end of a string¶
re.compile(r”.*[0-9]$”)
Check for a number at the end of a string.
import re
def end_num(S):
text = re.compile(r".*[0-9]$")
if text.match(S):
return True
else:
return False
# test
print(end_num('abcdef')) # False
print(end_num('abcdef6')) # True